import request from '../../../util/request';
import {userServer} from '../../../config/config';

/**
 * 存储权限
 */
function savePermission({permission, description}) {
	return request(userServer('/api/permission/savePermission'), {
		data: {permission, description}
	});
}

/**
 * 移除权限
 */
function removePermission({permissionId}) {
	return request(userServer('/api/permission/removePermission'), {
		data: {permissionId}
	});
}

/**
 * 更新权限
 */
function updatePermission({permissionId, permission, description}) {
	return request(userServer('/api/permission/updatePermission'), {
		data: {permissionId, permission, description}
	});
}

/**
 * 通过角色id获取权限列表
 */
function listPermissionByRoleId({roleId}) {
	return request(userServer('/api/permission/listPermissionByRoleId'), {
		data: {roleId}
	});
}

/**
 * 分页获取权限
 */
function pagePermission({pageNum, pageSize}) {
	return request(userServer('/api/permission/pagePermission'), {
		data: {pageNum, pageSize}
	});
}

export {
	savePermission,
	removePermission,
	updatePermission,
	listPermissionByRoleId,
	pagePermission,
}
